<template>
    <a-modal :bodyStyle="{ maxHeight: maxHeight + 'px', overflow: 'auto' }" :destroyOnClose="true" :width="880"
        :visible="visible" :confirmLoading="confirmLoading" :maskClosable="true" @ok="ok" @cancel="cancel"
        cancelText="关闭" :ok-button-props="{ props: { shape: 'round' } }"
        :cancel-button-props="{ props: { shape: 'round' } }">

        <a-spin :spinning="confirmLoading">
            <div class="table-page-search-wrapper">
                <LTable ref="KhyUseList" size="middle" rowKey="keyId" :columns="columns"
                    axiosUrl="/KhyUseController/page" :formAttributes="formAttributes" :showPagination="true"
                    :showQueryForm="true" @handleLoad="handleLoad" :rowSelection="{ onChange: onSelectChange }">
                </LTable>
            </div>
        </a-spin>
    </a-modal>
</template>

<script>
import LTable from '@/components/lt/LTable'
import {SysMixin} from '@/mixins/SysMixin'
export default {
    name: 'oldUserActiveAddForm',
    components: {
        LTable
    },
    mixins:[SysMixin],
    props: {
        mostColumns: {
            type: Number,
            default: 1
        },
        labelCol: {
            type: Object,
            default: function () {
                return {
                    sm: {
                        span: 6
                    }
                }
            }
        },
        wrapperCol: {
            type: Object,
            default: function () {
                return {
                    sm: {
                        span: 18
                    }
                }
            }
        },

    },
    data() {
        return {
            title: '详情',
            visible: false,
            confirmLoading: false,
            maxHeight: 1300,
            model: {},
            selectedRowKeys: [],
            dataSource: {},
            formAttributes: [
                { field: 'userNo', label: '用户手机号', component: 'input', condition: 'like' },
            ],
            columns: [
                {

                    title: '序号',
                    dataIndex: '',
                    key: 'rowIndex',
                    width: 60,
                    align: "center",
                    customRender: function (t, r, index) {
                        return parseInt(index) + 1;
                    }
                },
                {
                    title: '用户手机号',
                    dataIndex: 'userNo',
                },
            ],
        }
    },
    methods: {
        onSelectChange(selectedRowKeys) {
            this.selectedRowKeys = selectedRowKeys;
        },
        edit() {
            this.visible = true
        },
        ok() {
            let that = this;
            console.log(this.selectedRowKeys)
            if(this.selectedRowKeys.length>0){
                let data=[];
                for(let i=0;i<this.dataSource.length;i++){
                    if(this.selectedRowKeys.includes(this.dataSource[i].keyId)){
                        data.push(this.dataSource[i])
                    }
                }
                that.$emit('addRecord', data);
            }
           
            this.visible = false
        },
        cancel() {
            this.visible = false
        },
        handleLoad(that) {
            this.dataSource = that.localDataSource;
        }
    },

}
</script>
